<?php
require_once("../includes/config.inc.php");
validate_admin();
if($_POST)
{
	@extract($_POST);

	$fileUploadError = false;
	
	if($_FILES["varValue"]["error"] == 4){
		$varValue = $tmpName;
	}else{
		if ($_FILES["varValue"]["error"] > 0){
			$_SESSION['sessMsg'] = "Error: " . $_FILES["varValue"]["error"] . "<br />";
			$fileUploadError = true;
		}else{

			$location = '../images/';
			$chkExt = array('jpg','jpeg','png','gif');
			$fileUploadResult = imgUpload($_FILES['varValue'],$location,$isThumb=false,'','','','','',$chkExt);
			if($fileUploadResult[0]){
				$varValue = $fileUploadResult[1];
			}else{
				$fileUploadError = true;
				$_SESSION['sessMsg'] = $fileUploadResult[1];
			}		
		}
	}		
	
	if(!$fileUploadError){
		$sqlPE = " update tbl_config set 
		varValue = '$varValue'
		where varName = 'backgroundImage' 
		";
		executeQuery($sqlPE);
		$_SESSION['sessMsg'] = " Background Image Edited Successfully. ";
		header("location: ae_config.php");
		exit();
	}
}

	$sqlPD = " select * from tbl_config where varName = 'backgroundImage' ";
	$resPD = executeQuery($sqlPD);
	if($rowPD = mysql_fetch_array($resPD))
	{
		@extract($rowPD);
	}
?>